const app = getApp()
import util from '../../../utils/util'
import {
  GetZfpcCount,
  GetJbsjCount
} from '../../../config/api'

Page({

  /**
   * 页面的初始数据
   */
  data: {
    zfpcCount: '',
    jbsjCount: ''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let adminInfo = wx.getStorageSync('adminInfo')
    console.log('是否管理员：',!!adminInfo)

    let grider_storge = wx.getStorageSync('grider')
    this.setData({
      adminInfo,
      grider_storge
    })

    if (adminInfo){ // 判断管理员
      
    }else{
      this.getZfpcCount()
      this.getJbsjCount()
    }
  },

  getZfpcCount() {
    let that = this;
    let params = {
      grider_id: this.data.grider_storge.id
    }
    util.apiRequest(GetZfpcCount, params, null).then(r => {
      console.log('走访排查数：', r)
      that.setData({
        zfpcCount: r.data.data
      })
    })
  },

  getJbsjCount() {
    let that = this;
    let params = {
      grider_id: this.data.grider_storge.id
    }
    util.apiRequest(GetJbsjCount, params, null).then(r => {
      console.log('交办数：', r)
      that.setData({
        jbsjCount: r.data.data
      })
    })
  },

  toEventList(e) { // 网格长/网格员跳转事件列表
    let cat_id = e.currentTarget.dataset.cat_id;
    wx.navigateTo({
      url: '/pages/grid/griderEventList/griderEventList?cat_id=' + cat_id,
    })
  },

  toTelList() {
    wx.navigateTo({
      url: '/pages/grid/telephoneAppeal/telephoneAppeal',
    })
  },

  
})